#pragma once
#include <iostream>
#include <assert.h>
using namespace std;

class Date
{
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);

public:
	Date(int year = 1900, int month = 1, int day = 1);
	Date(const Date& d);
	~Date()
	{
		_year = 1900;
		_month = 1;
		_day = 1;
	}
	Date& operator=(const Date& d);

	bool operator>(const Date& d) const;
	bool operator==(const Date& d) const;
	bool operator>=(const Date& d) const;
	bool operator<(const Date& d) const;
	bool operator<=(const Date& d) const;
	bool operator!=(const Date& d) const;
	Date& operator+=(int day);
	Date operator+(int day) const;
	Date& operator-=(int day);
	Date operator-(int day) const;
	int operator-(const Date& d) const;
	Date& operator++();
	Date operator++(int);
	Date& operator--();
	Date operator--(int);

	
private:
	int GetMonthDay(int year, int month) const
	{
		assert(month >= 1 && month <= 12);

		static int monthDay[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

		if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
		{
			return 29;
		}

		return monthDay[month];
	}


private:
	int _year;
	int _month;
	int _day;
};
ostream& operator<<(ostream& out, const Date& d); 
istream& operator>>(istream& in, Date& d);
